# -*- coding: utf-8 -*-
import re
import scrapy


class GithubSpider(scrapy.Spider):
    name = 'github'
    allowed_domains = ['github.com']
    start_urls = ['https://github.com/login']

    def parse(self, response):
        yield scrapy.FormRequest.from_response(
            response,#自动的从response中寻找from表单
            formdata={"login":"1510804792@qq.com","password":"xyb.1206"},
            callback=self.agter_login

        )
    def agter_login(self,response):

        #查询网址的cookies
        #请求cookie
        Cookie = response.request.headers.get("Cookie")
        print("Cookie:%s"%Cookie.decode("utf-8"))
        #响应Ｃookie
        Cookie = response.headers.get("Set-Cookie")
        print("Set-Cookie:%s"%Cookie.decode("utf-8"))
        print(re.findall("xieyabinfuwu",response.body.decode()))
